/**
 * 由 CoCo 源代码计划解包器解包
 *
 * 模块 ID：402
 */

"use strict"

var n = require("./74")
var o = require("./349/192")
var i = require("./37")
var a = function () {
  var t = function (e, r) {
    return (t = Object.setPrototypeOf || {
      __proto__: []
    } instanceof Array && function (t, e) {
      t.__proto__ = e
    } || function (t, e) {
      for (var r in e) if (e.hasOwnProperty(r)) {
        t[r] = e[r]
      }
    })(e, r)
  }
  return function (e, r) {
    function n() {
      this.constructor = e
    }
    t(e, r)
    e.prototype = null === r ? Object.create(r) : (n.prototype = r.prototype, new n())
  }
}()
var u = function (t) {
  var e = "function" === typeof Symbol && Symbol.iterator
  var r = e && t[e]
  var n = 0
  if (r) {
    return r.call(t)
  }
  if (t && "number" === typeof t.length) {
    return {
      next: function () {
        if (t && n >= t.length) {
          t = undefined
        }
        return {
          value: t && t[n++],
          done: !t
        }
      }
    }
  }
  throw new TypeError(e ? "Object is not iterable." : "Symbol.iterator is not defined.")
}
var s = function (t) {
  function e() {
    var e = t.call(this) || this
    e.decodeMiddleCounters = Int32Array.from([0, 0, 0, 0])
    return e
  }
  a(e, t)
  e.prototype.decodeMiddle = function (t, r, n) {
    var i
    var /* [auto-meaningful-name] */y$return
    var s
    var /* [auto-meaningful-name] */v$return
    var /* [auto-meaningful-name] */this$decodeMiddleCounters = this.decodeMiddleCounters
    this$decodeMiddleCounters[0] = 0
    this$decodeMiddleCounters[1] = 0
    this$decodeMiddleCounters[2] = 0
    this$decodeMiddleCounters[3] = 0
    for (var h = t.getSize(), l = r[1], d = 0, p = 0; p < 6 && l < h; p++) {
      var g = o.a.decodeDigit(t, this$decodeMiddleCounters, l, o.a.L_AND_G_PATTERNS)
      n += String.fromCharCode("0".charCodeAt(0) + g % 10)
      try {
        for (i = undefined, y = u(this$decodeMiddleCounters), w = y.next(), undefined; !w.done; w = y.next()) {
          var y
          var w
          l += w.value
        }
      } catch (m) {
        i = {
          error: m
        }
      } finally {
        try {
          if (w && !w.done && (y$return = y.return)) {
            y$return.call(y)
          }
        } finally {
          if (i) {
            throw i.error
          }
        }
      }
      if (g >= 10) {
        d |= 1 << 5 - p
      }
    }
    n = e.determineFirstDigit(n, d)
    l = o.a.findGuardPattern(t, l, true, o.a.MIDDLE_PATTERN, new Int32Array(o.a.MIDDLE_PATTERN.length).fill(0))[1]
    for (p = 0; p < 6 && l < h; p++) {
      g = o.a.decodeDigit(t, this$decodeMiddleCounters, l, o.a.L_PATTERNS)
      n += String.fromCharCode("0".charCodeAt(0) + g)
      try {
        for (s = undefined, v = u(this$decodeMiddleCounters), _ = v.next(), undefined; !_.done; _ = v.next()) {
          var v
          var _
          l += _.value
        }
      } catch (A) {
        s = {
          error: A
        }
      } finally {
        try {
          if (_ && !_.done && (v$return = v.return)) {
            v$return.call(v)
          }
        } finally {
          if (s) {
            throw s.error
          }
        }
      }
    }
    return {
      rowOffset: l,
      resultString: n
    }
  }
  e.prototype.getBarcodeFormat = function () {
    return n.a.EAN_13
  }
  e.determineFirstDigit = function (t, e) {
    for (var r = 0; r < 10; r++) {
      if (e === this.FIRST_DIGIT_ENCODINGS[r]) {
        return t = String.fromCharCode("0".charCodeAt(0) + r) + t
      }
    }
    throw new i.a()
  }
  e.FIRST_DIGIT_ENCODINGS = [0, 11, 13, 14, 19, 25, 28, 21, 22, 26]
  return e
}(o.a)
exports.a = s
